import 'dart:typed_data';

import 'package:flutter_ble_plugin/flutter_ble_plugin.dart';
import 'package:flutter_ble_plugin/src/flutter_ble_plugin_method_channel.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_ble_plugin/src/flutter_ble_plugin_platform_interface.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';

class MockFlutterBlePluginPlatform
    with MockPlatformInterfaceMixin
    implements FlutterBlePluginPlatform {
  @override
  Future<String?> getPlatformVersion() => Future.value('42');

  @override
  Future<bool> isScanning() {
    // TODO: implement isScanning
    throw UnimplementedError();
  }

  @override
  Future<void> startScan() {
    // TODO: implement startScan
    throw UnimplementedError();
  }

  @override
  Future<void> stopScan() {
    // TODO: implement stopScan
    throw UnimplementedError();
  }

  @override
  Future<bool> connect(String deviceId) {
    // TODO: implement connect
    throw UnimplementedError();
  }

  @override
  Future<void> disconnect(String deviceId) {
    // TODO: implement disconnect
    throw UnimplementedError();
  }

  @override
  Future<bool> sendData(String deviceId, Uint8List data) {
    // TODO: implement sendData
    throw UnimplementedError();
  }
}

void main() {
  final FlutterBlePluginPlatform initialPlatform =
      FlutterBlePluginPlatform.instance;

  test('$MethodChannelFlutterBlePlugin is the default instance', () {
    expect(initialPlatform, isInstanceOf<MethodChannelFlutterBlePlugin>());
  });

  test('getPlatformVersion', () async {
    FlutterBlePlugin flutterBlePlugin = FlutterBlePlugin();
    MockFlutterBlePluginPlatform fakePlatform = MockFlutterBlePluginPlatform();
    FlutterBlePluginPlatform.instance = fakePlatform;

    expect(await flutterBlePlugin.getPlatformVersion(), '42');
  });
}
